package com.diver.flinkdemo.mapper.mysqlMapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.diver.flinkdemo.dto.xxt.MonthExerciseInfo;
import com.diver.flinkdemo.entity.xxt.MonthExercise;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
//@DS("doris")
public interface MonthExerciseMapper extends BaseMapper<MonthExercise> {

    @Update("update month_exercise set step = #{me.step} ,class_rank=#{me.classRank},distance = #{me.distance} , heat = #{me.heat},create_time = #{toDayTime}, "+
            "average_step = #{me.averageStep},grade_rank = #{me.gradeRank},school_rank = #{me.schoolRank} where student_card_id=#{me.studentCardId} and create_time = #{me.createTime}")
    void doUpdateMonthExercise(@Param("me") MonthExercise me, @Param("toDayTime")Long toDayTime);

    @Update("update month_exercise set step = #{me.step} ,distance = #{me.distance} , heat = #{me.heat}, average_step = #{me.averageStep}"+
            " where id=#{me.id}")
    void doUpdateStep(@Param("me")MonthExercise me);

    @Delete("delete from month_exercise where student_card_id=#{studentCardId}")
    int delByStudentCardId(String studentCardId);

    @Select("select student_card_id,step,distance,heat,average_step,class_rank,grade_rank,school_rank,create_time from month_exercise where student_card_id = #{studentCardId} order by create_time desc ")
    List<MonthExerciseInfo> getMonthlySportByStudentCardId(@Param("studentCardId")String studentCardId);
}
